# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.http import HttpResponse
from django.shortcuts import render
from open_class.models import Category
import json

# Create your views here.

# def test(request):
#     res = Category.objects.all()
#     content = ''
#     content = content + '<html>'
#     for item in res:
#         content = content + '<li>' + str(item)+ '</li>'
#     content = content + '</html>'
#     return HttpResponse(content)


def test(request):
    res = Category.objects.all()
    content = []
    for item in res :
        content.append(item.getattrs(args=['name','summary','create_time','update_time']))
    return HttpResponse(json.dumps(content))  #dumps:是json下的一个方法，这里是把字典里的内容转换成json格式